<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="shortcut icon" href="<!--{eval echo register_static('img/touch-icon-57x57.png');}-->">

    <title>粉粉管理系统</title>

    <!-- Bootstrap core CSS -->
    <link href="<!--{eval echo register_static('css/bootstrap.min.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('css/bootstrap-reset.css');}-->" rel="stylesheet">

    <!--Animation css-->
    <link href="<!--{eval echo register_static('css/animate.css');}-->" rel="stylesheet">

    <!--Icon-fonts css-->
    <link href="<!--{eval echo register_static('assets/font-awesome/css/font-awesome.css');}-->" rel="stylesheet" />
    <link href="<!--{eval echo register_static('assets/ionicon/css/ionicons.min.css');}-->" rel="stylesheet" />

    <link href="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.css');}-->" rel="stylesheet">

    <!-- Plugins css -->
    <link href="<!--{eval echo register_static('assets/modal-effect/css/component.css');}-->" rel="stylesheet">

    <!-- DataTables -->
    <link rel="stylesheet" href="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.css" rel="stylesheet');}-->" />

    <!-- Custom styles for this template -->
    <link href="<!--{eval echo register_static('css/style.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('css/helper.css');}-->" rel="stylesheet">

    <!-- My styles for this template -->
    <link href="<!--{eval echo register_static('css/common.css');}-->" rel="stylesheet">

</head>

<body>

<!-- Aside Start-->
<!--{template admin_v2/leftside}-->
<!-- Aside Ends-->


<!--Main Content Start -->
<section class="content">

    <!-- Header -->
    <!--{template admin_v2/header}-->
    <!-- Header Ends -->


    <!-- Page Content Start -->
    <!-- ================== -->

    <div class="wraper container-fluid diary-topics">

        <div class="row">
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">达人管理</h3>
                    </div>
                    <br>
                    <div class="form-inline">
                        <div class="form-group">
                            <label>
                                筛选:
                            </label>
                            <div class="form-group">
                                <select class="form-control" id="masterType" name="status">
                                    <option value="0">申请中达人</option>
                                    <option value="1">正式达人</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <select class="form-control" id="vv" name="vv">
                                    <option value="0">未加V用户</option>
                                    <option value="1">已加V用户</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <select class="form-control" id="label" name="label">
                                    <option value="0">默认类别</option>
                                    <option value="1">情感鸡汤</option>
                                    <option value="10">搞笑能手</option>
                                    <option value="11">原创达人</option>
                                    <option value="12">二次元</option>
                                    <option value="13">混娱乐圈</option>
                                    <option value="5">健康</option>
                                    <option value="6">美妆</option>
                                    <option value="7">星座</option>
                                    <option value="9">美图</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <select class="form-control" id="orderBy" name="orderBy">
                                    <option value="id">默认排序方式</option>
                                    <option value="fans_count">按粉丝数排序</option>
                                    <option value="level">按等级数排序</option>
                                    <option value="diaryTimes">按点滴数排序</option>
                                    <option value="topicTimes">按话题数排序</option>
                                    <option value="likeMeTimes">按被喜欢排序</option>
                                    <option value="last_activity">按活跃时间排序</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <div id="page"></div>
                            </div>
                        </div>
                        <button class="btn btn-success" id="verifiedlist" type="button">全部大V(订阅号)</button>
                        <button class="btn btn-success" id="verifiedtpl" type="button">增加大V(订阅号)</button>
                        <form style="float:right;"  role="form" class="form-inline">
                            <div class="form-group">
                                <input type="text" name="uid" id="uid" placeholder="输入UID" class="form-control">
                            </div>
                            <button class="btn btn-success m-l-10" id="checkUid" type="button">查看</button>
                        </form>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <table id="datatable" class="table table-striped table-bordered">
                                    <thead>
                                    <tr>
                                        <th style="width: 5%;">UID</th>
                                        <th style="width: 7%;">昵称</th>
                                        <th style="width: 4%;">勋章</th>
                                        <th style="width: 5%;">申请时间</th>
                                        <th style="width: 5%;">类别</th>
                                        <th style="width: 5%;">加V</th>
                                        <th style="width: 5%;">等级</th>
                                        <th style="width: 5%;">粉丝</th>
                                        <th style="width: 5%;">点滴</th>
                                        <th style="width: 5%;">话题</th>
                                        <th style="width: 5%;">被喜欢</th>
                                        <th style="width: 20%">达人宣言</th>
                                        <th>状态</th>
                                        <th>最后活跃时间</th>
                                        <th style="width: 8%;">操作</th>
                                    </tr>
                                    </thead>

                                    <tbody id="viewList">

                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <!-- Page Content Ends -->
    <!-- ================== -->

    <div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">

    </div><!-- /.modal -->


    <!-- Footer Start -->
    <!--{template admin_v2/footer}-->
    <!-- Footer Ends -->



</section>
<!-- Main Content Ends -->


<!-- js placed at the end of the document so the pages load faster -->
<script src="<!--{eval echo register_static('js/jquery.js');}-->"></script>
<script src="<!--{eval echo register_static('js/bootstrap.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/pace.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/wow.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/jquery.nicescroll.js');}-->" type="text/javascript"></script>

<script src="<!--{eval echo register_static('js/jquery.app.js');}-->"></script>
<script src="<!--{eval echo register_static('laytpl/laytpl.js');}-->"></script>
<script src="<!--{eval echo register_static('layer/layer.js');}-->"></script>
<script src="<!--{eval echo register_static('laydate/laydate.js');}-->"></script>
<script src="<!--{eval echo register_static('laypage/laypage.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/datatables/dataTables.bootstrap.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.init.js');}-->"></script>

<!-- Modal-Effect -->
<script src="<!--{eval echo register_static('assets/modal-effect/js/classie.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/modal-effect/js/modalEffects.js');}-->"></script>
<script src="<!--{eval echo register_static('js/common.js');}-->"></script>
<script id="list" type="text/html">
    {{# for(var i=0,len=d.length;i< len;i++){ }}
    <tr>
        <td><a href="http://ffweb.ffrj.net/profile.php?ac=index&id={{d[i].uid}}">{{d[i].uid}}</a></td>
        <td><a target="_blank" href="admin.php?ac=user_profile&uid={{d[i].uid}}">{{d[i].user.nickname}}</a></td>
        <td>{{d[i].medal_id}}</td>
        <td>{{laytpl.dateTime(d[i].dateline)}}</td>
        <td>{{laytpl.masterType(d[i].label)}}</td>
        <td>{{laytpl.vv(d[i].verified)}}</td>
        <td>{{d[i].level}}</td>
        <td>{{d[i].fans_count}}</td>
        <td>{{d[i].diaryTimes}}</td>
        <td>{{d[i].topicTimes}}</td>
        <td>{{d[i].likeMeTimes}}</td>
        <td>{{d[i].content}}</td>
        <td>{{laytpl.status(d[i].status)}}</td>
        <td>{{laytpl.dateTime(d[i].la_act)}}</td>
        <td>
            <div class="btn-group">
                <button type="button" class="btn btn-info">管理</button>
                <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <span class="caret"></span>
                    <span class="sr-only">Toggle Dropdown</span>
                </button>
                <ul class="dropdown-menu">
                    <li><a href="javascript:void(0);" class="masterAction" data-status="1" data-uid="{{d[i].uid}}">添加达人</a></li>
                    <li><a href="javascript:void(0);" class="masterAction" data-status="2" data-uid="{{d[i].uid}}">忽略达人</a></li>
                    <li><a href="javascript:void(0);" class="masterAction" data-status="3" data-uid="{{d[i].uid}}">撤销达人</a></li>
                    <li><a href="javascript:void(0);" class="masterVerified" data-verified="1" data-uid="{{d[i].uid}}">认证加V</a></li>
                    <li><a href="javascript:void(0);" class="masterVerified" data-verified="0" data-uid="{{d[i].uid}}">取消大V</a></li>
                </ul>
            </div>
        </td>
    </tr>
    {{# } }}
</script>
<script id="vertpl" type="text/html">
    <form  role="form" class="form-inline">
        <div class="form-group">
            <input type="text" name="vuid" id="vuid" placeholder="输入UID" class="form-control">
        </div>
        <button class="btn btn-success addVerified"  type="button">创建</button>
    </form>
</script>
<script type="text/javascript">
    var start = 0;
    var length = 20;
    var status = 0;
    var verified = 0;
    var orderBy = 'id';
    var uid = 0;
    var label=0;

    var params = function(){
        return {uid:uid,label:label,orderBy:orderBy,start:start,status:status,length:length,verified:verified,action:'getMasterList',do:'masterAuth'};
    }

    var displayRes = function(data){
        laytpl($('#list').html()).render(data,function(html){
            $('#viewList').html(html);
        });
    }

    $(document).on('click','#verifiedtpl',function () {
        laytpl($('#vertpl').html()).render({},function (html) {
            layer.open({
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['420px', '240px'], //宽高
                content: html
            });
        })
    });
    $(document).on('click','.addVerified',function () {
        var data ={}
        var uid = $('#vuid').val();
        data['uid']    = uid
        data['verified'] = 1;
        data['action'] = 'setVerified';
        data['do']     = 'masterAuth';
        request(data, resDisplay);
    });
    $(document).on('click','.masterAction',function(){
        var data={}
        data['uid'] = $(this).data('uid');
        data['status'] = $(this).data('status');
        data['action'] = 'setMaster';
        data['do'] = 'masterAuth';
        request(data, resDisplay);
    });

    $(document).on('click','.masterVerified',function(){
        var data={}
        data['uid'] = $(this).data('uid');
        data['verified'] = $(this).data('verified');
        data['action'] = 'setVerified';
        data['do'] = 'masterAuth';
        request(data, resDisplay);
    });

    $(document).on('click','#verifiedlist',function () {
        uid = 0;
        verified = 2;
        request(params(), displayRes);
    });

    $(document).on('change','#label',function () {
        uid = 0;
        label=$(this).val()
        request(params(), displayRes);
    });

    $(document).on('change','#masterType',function () {
        uid = 0;
        status=$(this).val()
        request(params(), displayRes);
    });
    $(document).on('change','#vv',function () {
        uid = 0;
        verified = $(this).val()
        request(params(), displayRes);
    })

    $(document).on('change','#orderBy',function () {
        uid = 0;
        orderBy = $(this).val();
        request(params(), displayRes);
    })

    $(document).on('click','#checkUid',function () {
        uid = $('#uid').val();
        request(params(), displayRes);
    })
    laypage({
        cont: document.getElementById('page'), //容器。值支持id名、原生dom对象，jquery对象,
        pages: 800, //总页数
        skin: 'molv', //加载内置皮肤，也可以直接赋值16进制颜色值，如:#c00
        groups: 8, //连续显示分页数
        jump:function(obj){
            var page = obj.curr;
            start = (page-1)*length;
            request(params(), displayRes);
        }
    });

//    $(function(){
//        request(params(), displayRes);
//    });
//

    laytpl.dateTime= function (time) {
        if(!!time){
            return new Date(parseInt(time) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
        }
        return '无';
    }
    laytpl.masterType = function (v) {
        var type = '未知';
        switch(v){
            case "1":
               type = "情感鸡汤";
                break;
            case "5":
                type = "健康";
                break;
            case "6":
                type = "美妆";
                break;
            case "7":
                type = "星座";
                break;
            case "9":
                type = "美图";
                break;
            case "10":
                type = "搞笑能手";
                break;
            case "11":
                type = "原创达人";
                break;
            case "12":
                type = "二次元";
                break;
            case "13":
                type = "混娱乐圈";
                break;
        }
        return type;
    }
    laytpl.vv = function (v) {
       if(v == 0){
           return '<i class="ion-close"></i>';
       }
        return '<i class="ion-checkmark-round"></i>';
    }
    laytpl.status = function(v){
        var s = '申请中';
        switch(v){
            case '0':
                s = '申请中';
                break;
            case '1':
                s = '达人';
                break;
            case '2':
                s = '申请失败';
                break;
            case '3':
                s = '被撤销';
                break;
        }
        return s;
    }
</script>
</body>
</html>
